<%--
 *  File:    CountyAreaTerminalMap.jsp
 *  @Author: Jackyin
 *  Date:    2011/03/2
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
    String strModuleName = "COM";
 	String strTableName = "v_zylcountyareaterminalsummary";
 	String privilegeCode = "10350";   
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="p_zylcountyareaterminalsummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/summary.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector searchresults = (Vector)pageContext.getAttribute("searchresults");
	HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  	if(searchresults == null)
  	{
  		searchresults = new Vector();
  	}
%>



<script language="JavaScript" >
var popwindow;

function page_summary(actionvalue,orderbyname){
  	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "CountyAreaTerminalMap.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

function page_add(){
	  if(!checkForm(document.cform)) return;
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}
function setTerminal(userid,terminalname,terminalid,terminalcode,terminaltype){
	var currentnum = document.cform.currentnum.value;
	document.cform['terminalname'+currentnum].value=terminalname;
	document.cform['terminalid'+currentnum].value=terminalid;
	document.cform['terminalcode'+currentnum].value=terminalcode;
	document.cform['terminaltype'+currentnum].value=terminaltype;
}

function popCountyArea(num){
	if(popwindow!=null) popwindow.close();
 	if(num != null || num == ''){
		document.cform.currentnum.value=num;
 	}else{
 	 	document.cform.currentnum.value='';
 	}
 	
    url = 'CountyAreaAllWindow.jsp?<%= OvalTools.randomURL() %>';
    attribute = 'height=300, width=500,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';

	popwindow = window.open(url,'newwindow', attribute);
}


function popTerminal(num){
	if(popwindow!=null) popwindow.close();
	if(num != null || num == ''){
		document.cform.currentnum.value=num;
 	}else{
 	 	document.cform.currentnum.value='';
 	}

	var currentnum = document.cform.currentnum.value;
    url = 'TerminalAllWindow.jsp?<%= OvalTools.randomURL() %>';
    attribute = 'height=300, width=500,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';

	popwindow = window.open(url,'newwindow', attribute);
}

function setCountyArea(userid,countyareaname,countyareaid,countyareacode){
	var currentnum = document.cform.currentnum.value;
	document.cform['countyareaname'+currentnum].value=countyareaname;
	document.cform['countyareacode'+currentnum].value=countyareacode;
	document.cform['countyareaid'+currentnum].value=countyareaid;
}

function isModify(checkname,num){
	var checkvalue = document.cform[checkname+num].value;
	var oldvalue = document.cform['old'+checkname+num].value;
	if(Trim(checkvalue)==Trim(oldvalue)){
		return false;
	}else{
		return true;
	}
}



function checkModify(){
	var numrows = document.cform.numrows.value;
	for (i=0;i<numrows;i++){
		if(isModify('businessareaid',i)){
			document.cform['mdflag'+i].value=1;
			continue;
		}
		if(isModify('userid',i)){
			document.cform['mdflag'+i].value=1;
			continue;
		}
		
		if(isModify('istarget',i)){
			document.cform['mdflag'+i].value=1;
			continue;
		}
		if(isModify('hasprotocol',i)){
			document.cform['mdflag'+i].value=1;
			continue;
		}		
	}
}
function page_save(){
	//checkModify();
	cform.actionname.value = "save";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}

var index = 0;
function mathindex(com){
    if(com.checked){
    	index++;
    }else{
    	index--;
    }
}

</script>

</head>
<body>
<%-- //--------------------------------------  page location --%>
	
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
    <custom:hidden property="pagename" value="p_zylcountyareaterminalsummary"/>
    <input type="hidden" name="actionname">
	<input type="hidden" name="currentnum">
	<input type="hidden" name="flags" value="0">
	<input type="hidden" name="numrows" value="<%=searchresults.size() %>">
	<%@ include file="/inc/PageLocation.inc" %>
	<table width="100%" cellspacing="0" border="0" cellpadding="0">
	 	<tr>
	     	<td >
	    <table width="100%" border="0" cellspacing="0">
        <tr>
          <td class="summary_top" width="10%" colspan="3"></td>
        </tr>
        <%@ include file="/inc/SummarySearch.inc" %>
      </table>
	     	</td>
	    </tr>
	    <tr> 
		    <td> 
		      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" >
		        <tr class="deepblue-left">
				  <td width="20px" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
		          <td class="title_center" width="150px"><a href="javascript:page_summary('orderby','countyareacode')"><%= label.getLabelName("L_CountyArea") %></a></td>
		          <td class="title_center" width="150px"><a href="javascript:page_summary('orderby','terminalcode')"><%= label.getLabelName("L_Terminal") %></a></td>
		          <td class="title_center" width="20px">&nbsp;</td>
		        </tr>
		        <%
	            	int i = 0;
	             	String strClassType = new String();
	          	%>
		         <logic:iterate id="onerow" collection="<%= searchresults %>" indexId="idx">
		           	<%
		            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
		            	if(i%2 == 1)
		            	{
		              		strClassType = "td-listrom";
		            	}else{
		              		strClassType = "";
		            	}
		            	i++;
		            	
		          	%>
		          	<tr id="tr<%=idx %>" class="none">
		          		<td id="td" class="title_left" >
		                    <input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("countyareaorgmapid") )%>" class="checkbox">
		            		<custom:hidden property="mdflag" colIndex="<%=idx %>" value="0"/>
		            		<custom:hidden name="onerow" property="countyareaorgmapid" colIndex="<%=idx %>"/>
		            		
		            	</td>
		            		            	
						<td class="title_left">
							<custom:hidden name="onerow" property="countyareaid" changedName="oldcountyareaid" colIndex="<%=idx %>"/>
							<custom:hidden name="onerow" property="countyareaid" colIndex="<%=idx %>"/>
				           	<custom:write name="onerow" property="countyareacode"/>&nbsp;&nbsp;&nbsp;&nbsp;
				           	 	<custom:write name="onerow" property="countyareaname"/>
						</td> 
						<td class="title_left">
							<custom:hidden name="onerow" property="terminalid" colIndex="<%=idx %>"/>
							<custom:hidden name="onerow" property="terminaltype" colIndex="<%=idx %>"/>
							<custom:write name="onerow" property="terminalcode" />&nbsp;&nbsp;&nbsp;&nbsp;
							<custom:write name="onerow" property="terminalname" />
						</td> 
				    <td>
		           		&nbsp;
		           </td>
		     	 </logic:iterate>
		     	 <tr class="none">
		           <td>&nbsp;</td>
		           <td class="title_left">
		           	<custom:hidden name="details"  property="countyareaid" />
		           	<custom:text name="details"  property="countyareacode" />
		           	<a onclick="popCountyArea()"><custom:button type="3" value="*"/></a>
					<custom:text property="countyareaname" name="details" command="notnull" label="L_BusinessAreaName" readonly="true"/>
					
		           </td>
		           <td class="title_left">
		          
		            <custom:hidden property="terminalid" name="details" />
		           	 	<custom:hidden property="terminaltype" name="details" />
		           	<custom:text property="terminalcode" name="details" />
		           	<a onclick="popTerminal()"><custom:button type="3" value="*"/></a>
		           	<custom:text property="terminalname" name="details" command="notnull" label="L_Employee" readonly="true"/>
		           	
	           </td>
		         <td>
		           		&nbsp;
		           </td>
		           
			     </tr>
		      <%@ include file="/inc/SummaryAction.inc" %>
		      </table>	      
		      </td>
		      </tr>
		      <tr>
		      <td>
		      
		      <table width="100%" cellspacing="0" cellpadding="0">
		        <tr> 
		          <td class="summary_top"></td>
		        </tr>
		        <tr>
				     <td class="td_center">
						<a onclick="page_add()"><custom:button type="2" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
						<a onclick="page_delete()"><custom:button type="2" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
						
					 </td>
				</tr>
		      </table>
		    </td>
	  </tr>
	</table>
</form>
</body>
</html>
